JointDef Class
Description:
A record for creating JointDef objects.
distance
Type: Function.
Description:
Creates a distance joint definition.
Signature:
distance: function(self: JointDefClass,
canCollide: boolean,
bodyA: string,
bodyB: string,
anchorA: Vec2,
anchorB: Vec2,
frequency?: number --[[0.0]],
damping?: number --[[0.0]]): JointDef
Parameters:
Parameter | Type | Description |
---|---|---|
canCollide | boolean | Whether or not the physics body connected to joint will collide with each other. |
bodyA | string | The name of first physics body to connect with the joint. |
bodyB | string | The name of second physics body to connect with the joint. |
anchorA | Vec2 | The position of the joint on the first physics body. |
anchorB | Vec2 | The position of the joint on the second physics body. |
frequency | number | The frequency of the joint, in Hertz (default is 0.0). |
damping | number | The damping ratio of the joint (default is 0.0). |
Returns:
Return Type | Description |
---|---|
JointDef | The new joint definition. |
friction
Type: Function.
Description:
Creates a friction joint definition.
Signature:
friction: function(self: JointDefClass,
canCollide: boolean,
bodyA: string,
bodyB: string,
worldPos: Vec2,
maxForce: number,
maxTorque: number): JointDef
Parameters:
Parameter | Type | Description |
---|---|---|
canCollide | boolean | Whether or not the physics body connected to joint will collide with each other. |
bodyA | Body | The name of first physics body to connect with the joint. |
bodyB | Body | The name of second physics body to connect with the joint. |
worldPos | Vec2 | The position of the joint in the game world. |
maxForce | number | The maximum force that can be applied to the joint. |
maxTorque | number | The maximum torque that can be applied to the joint. |
Returns:
Return Type | Description |
---|---|
Joint | The new friction joint definition. |
gear
Type: Function.
Description:
Creates a gear joint definition.
Signature:
gear: function(self: JointDefClass,
canCollide: boolean,
jointA: string,
jointB: string,
ratio?: number --[[1.0]]): JointDef
Parameters:
Parameter | Type | Description |
---|---|---|
canCollide | boolean | Whether or not the physics bodies connected to the joint can collide with each other. |
jointA | Joint | The name of first joint to connect with the gear joint. |
jointB | Joint | The name of second joint to connect with the gear joint. |
ratio | number | The gear ratio (default is 1.0). |
Returns:
Return Type | Description |
---|---|
Joint | The new gear joint definition. |
spring
Type: Function.
Description:
Creates a new spring joint definition.
Signature:
spring: function(self: JointDefClass,
canCollide: boolean,
bodyA: string,
bodyB: string,
linearOffset: Vec2,
angularOffset: number,
maxForce: number,
maxTorque: number,
correctionFactor?: number --[[1.0]]): JointDef
Parameters:
Parameter | Type | Description |
---|---|---|
canCollide | boolean | Whether the connected bodies should collide with each other. |
bodyA | Body | The name of first body connected to the joint. |
bodyB | Body | The name of second body connected to the joint. |
linearOffset | Vec2 | Position of body-B minus the position of body-A, in body-A's frame. |
angularOffset | number | Angle of body-B minus angle of body-A. |
maxForce | number | The maximum force the joint can exert. |
maxTorque | number | The maximum torque the joint can exert. |
correctionFactor | number | Optional correction factor, defaults to 1.0. |
Returns:
Return Type | Description |
---|---|
Joint | The created joint definition. |
prismatic
Type: Function.
Description:
Creates a new prismatic joint definition.
Signature:
prismatic: function(self: JointDefClass,
canCollide: boolean,
bodyA: string,
bodyB: string,
worldPos: Vec2,
axisAngle: number,
lowerTranslation?: number --[[0.0]],
upperTranslation?: number --[[0.0]],
maxMotorForce?: number --[[0.0]],
motorSpeed?: number --[[0.0]]): JointDef
Parameters:
Parameter | Type | Description |
---|---|---|
canCollide | boolean | Whether the connected bodies should collide with each other. |
bodyA | Body | The name of first body connected to the joint. |
bodyB | Body | The name of second body connected to the joint. |
worldPos | Vec2 | The world position of the joint. |
axisAngle | number | The axis angle of the joint. |
lowerTranslation | number | Optional lower translation limit, defaults to 0.0. |
upperTranslation | number | Optional upper translation limit, defaults to 0.0. |
maxMotorForce | number | Optional maximum motor force, defaults to 0.0. |
motorSpeed | number | Optional motor speed, defaults to 0.0. |
Returns:
Return Type | Description |
---|---|
MotorJoint | The created prismatic joint definition. |
pulley
Type: Function.
Description:
Create a pulley joint definition.
Signature:
pulley: function(self: JointDefClass,
canCollide: boolean,
bodyA: string,
bodyB: string,
anchorA: Vec2,
anchorB: Vec2,
groundAnchorA: Vec2,
groundAnchorB: Vec2,
ratio?: number --[[1.0]]): JointDef
Parameters:
Parameter | Type | Description |
---|---|---|
canCollide | boolean | Whether or not the connected bodies will collide with each other. |
bodyA | Body | The name of first physics body to connect. |
bodyB | Body | The name of second physics body to connect. |
anchorA | Vec2 | The position of the anchor point on the first body. |
anchorB | Vec2 | The position of the anchor point on the second body. |
groundAnchorA | Vec2 | The position of the ground anchor point on the first body in world coordinates. |
groundAnchorB | Vec2 | The position of the ground anchor point on the second body in world coordinates. |
ratio | number | [optinal] The pulley ratio (default 1.0). |
Returns:
Return Type | Description |
---|---|
Joint | The pulley joint definition. |
revolute
Type: Function.
Description:
Create a revolute joint definition.
Signature:
revolute: function(self: JointDefClass,
canCollide: boolean,
bodyA: string,
bodyB: string,
worldPos: Vec2,
lowerAngle?: number --[[0.0]],
upperAngle?: number --[[0.0]],
maxMotorTorque?: number --[[0.0]],
motorSpeed?: number --[[0.0]]): JointDef
Parameters:
Parameter | Type | Description |
---|---|---|
canCollide | boolean | Whether or not the connected bodies will collide with each other. |
bodyA | Body | The name of first physics body to connect. |
bodyB | Body | The name of second physics body to connect. |
worldPos | Vec2 | The position in world coordinates where the joint will be created. |
lowerAngle | number | [optinal] The lower angle limit (radians) (default 0.0). |
upperAngle | number | [optinal] The upper angle limit (radians) (default 0.0). |
maxMotorTorque | number | [optinal] The maximum torque that can be applied to the joint to achieve the target speed (default 0.0). |
motorSpeed | number | [optinal] The desired speed of the joint (default 0.0). |
Returns:
Return Type | Description |
---|---|
MotorJoint | The revolute joint definition. |
rope
Type: Function.
Description:
Create a rope joint definition.
Signature:
rope: function(self: JointDefClass,
canCollide: boolean,
bodyA: string,
bodyB: string,
anchorA: Vec2,
anchorB: Vec2,
maxLength: number): JointDef
Parameters:
Parameter | Type | Description |
---|---|---|
canCollide | boolean | Whether or not the connected bodies will collide with each other. |
bodyA | Body | The name of first physics body to connect. |
bodyB | Body | The name of second physics body to connect. |
anchorA | Vec2 | The position of the anchor point on the first body. |
anchorB | Vec2 | The position of the anchor point on the second body. |
maxLength | number | [optinal] The maximum distance between the anchor points (default 0.0). |
Returns:
Return Type | Description |
---|---|
Joint | The rope joint definition. |
weld
Type: Function.
Description:
Creates a weld joint definition.
Signature:
weld: function(self: JointDefClass,
canCollide: boolean,
bodyA: string,
bodyB: string,
worldPos: Vec2,
frequency?: number --[[0.0]],
damping?: number --[[0.0]]): JointDef
Parameters:
Parameter | Type | Description |
---|---|---|
canCollide | boolean | Whether or not the bodies connected to the joint can collide with each other. |
bodyA | Body | The name of first body to be connected by the joint. |
bodyB | Body | The name of second body to be connected by the joint. |
worldPos | Vec2 | The position in the world to connect the bodies together. |
frequency | number | [optional] The frequency at which the joint should be stiff, defaults to 0.0. |
damping | number | [optional] The damping rate of the joint, defaults to 0.0. |
Returns:
Return Type | Description |
---|---|
Joint | The newly created weld joint definition. |
wheel
Type: Function.
Description:
Creates a wheel joint definition.
Signature:
wheel: function(self: JointDefClass,
canCollide: boolean,
bodyA: string,
bodyB: string,
worldPos: Vec2,
axisAngle: number,
maxMotorTorque?: number --[[0.0]],
motorSpeed?: number --[[0.0]],
frequency?: number --[[2.0]],
damping?: number --[[0.7]]): JointDef
Parameters:
Parameter | Type | Description |
---|---|---|
canCollide | boolean | Whether or not the bodies connected to the joint can collide with each other. |
bodyA | Body | The name of first body to be connected by the joint. |
bodyB | Body | The name of second body to be connected by the joint. |
worldPos | Vec2 | The position in the world to connect the bodies together. |
axisAngle | number | The angle of the joint axis in radians. |
maxMotorTorque | number | [optional] The maximum torque the joint motor can exert, defaults to 0.0. |
motorSpeed | number | [optional] The target speed of the joint motor, defaults to 0.0. |
frequency | number | [optional] The frequency at which the joint should be stiff, defaults to 2.0. |
damping | number | [optional] The damping rate of the joint, defaults to 0.7. |
Returns:
Return Type | Description |
---|---|
MotorJoint | The newly created wheel joint definition. |